The Default CDEF is a simple aid for programmers that draws outlines around default buttons. Default is unique because it correctly handles all sizes and colors, it works in ResEdit templates and finished applications, and it can automatically manage the Return and Enter keys. Default can also draw push buttons, check boxes, and radio buttons using the window’s font. DefaultItem, which is code for a user item procedure, is also provided as an alternative solution.
__ Instructions __
Default is a control definition function that you can copy and paste into your application. The Default CDEF enhances the System’s standard control definition 0. If the last character of a button’s title is an ‘@’ (an “at” or an “each” symbol), the button is drawn with an outline indicating it is the default button. The trailing ‘@’ is not displayed.
When Color QuickDraw is available, outlines are drawn in the same color as the button’s frame. If the button is inactive, the outline is grayed. If System 7 or later is being used, the outline is dimmed in the same way as the grayishTextOr mode. If the Default CDEF is in the same file as your application’s DITL resources, ResEdit will display the outlines drawn by Default. You do not need to write any code to use Default.
A dialog’s default button can be changed at any time in your application simply by changing the appropriate button titles. However, you, the programmer, are responsible for making sure there is only one default button. If you are not using a filterProc, Default ensures that pressing Return or Enter is the same as clicking the default button. The Dialog Manager will also highlight the default button when Return or Enter is pressed. If you are using your own filterProc, you must perform these tasks.
If the last character of a control’s title is an ‘ƒ’, the control is drawn using the window’s current font. Push buttons, check boxes, and radio buttons will look the same as if you used a CNTL resource with the useWFont variation code. This feature is especially useful for Control Panel devices. If you need a default button using the window’s font, end the button’s title with ‘ƒ@’.
DefaultItem is a user item procedure that draws the same outlines as Default. If you prefer to draw outlines with user items or if you are writing a desk accessory, DefaultItem is for you. The Default CDEF is not compatible with the resource numbering scheme used by desk accessories.
__ Compatibility __
Default works on any Macintosh model with any System version. Default is 32-bit clean. Except for drawing the outline, Default lets the System file’s CDEF 0 do virtually everything. Thus, Default’s buttons do anything that normal buttons do.
Be warned that Default uses the contrlData field of a ControlRecord (which is okay since it is reserved for CDEFs). If your application does something strange with this field, Default will not work.
__ Bugs __
The outline will not update if the outline needs updating and the button does not, and UpdtControl or UpdtDialog is being used to update the controls. This problem does not occur with normal modal dialogs and rarely occurs with modeless dialogs. Unfortunately, there isn’t a clean solution to this problem. If you have this problem, you can call Draw1Control for the default button on update events or use DrawControls or DrawDialog instead of UpdtControl and UpdtDialog.
If you have a default button and you aren’t using a filterProc, pressing Return or Enter will click the default button even if the button is hidden. This is a bug in the Dialog Manager. If you have this problem, you must change the default button to a normal button before you call HideDItem or HideControl.
If you have a dialog with an edit text item and you want to use a different font style, transfer mode, or font size with the dialog, you must adjust the lineHeight, fontAscent, txFont, txFace, txMode, and txSize fields of the dialog’s textH TextEdit handle as needed. This is another bug in the Dialog Manager. If you just want a different font, SetDAFont works correctly.
Please report any other bugs to any of the addresses listed below. Thanks to those programmers who did unusual things with their buttons and reported bugs — they helped make Default robust.
__ History __
1.0 — first release
1.1 — fixed bug with HideControl and default buttons
1.2 — updated to support new 32-bit clean CDEF messages
1.3 — fixed bug with DragControl
1.4 — fixed bug converting between default buttons and normal buttons;
improved outlines for unusually sized default buttons
1.5 — forced ResEdit to refresh default buttons correctly
2.0 — added automatic Return and Enter support for default buttons;
added window font feature for push buttons, check boxes, and radio buttons;
restructured code to reduce size of CDEF
2.1 — updated to follow Apple’s new way of drawing default outlines
2.2 — fixed rare bug with Standard File Package;
removed ResEdit updating code;
added more optimizations to reduce code size;
added sample code for default user item procedure
2.3 — updated to support System 7 grayishTextOr disabling
2.4 — updated to use Gestalt;
streamlined code for automatic compiler optimization
__ Distribution __
Default is available for free. You may copy and redistribute Default provided that you include this documentation and that Default is not modified in any way. Default is owned and copyrighted by Lim Unlimited.
You may include Default in any software that you distribute provided that Lim Unlimited is given a free, fully functional, and fully supported copy of your software. This requirement does not apply to software developed solely for your own personal or internal use.
The source code to Default is available on request. You can obtain a copy via electronic mail or by sending a disk and a stamped, self-addressed envelope via postal mail. The source code may not be redistributed without the permission of Lim Unlimited. You may not distribute modified versions of the source code or any software derived from the source code.